package com.ycl.bookstore.controller;

import com.ycl.bookstore.common.Result;
import com.ycl.bookstore.service.CouponService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController()
@RequestMapping("/coupon")
public class CouponController {

    @Resource
    private CouponService couponService;

    /**
     * 领取签到优惠卷
     * @param couponId
     * @return
     */
    @PutMapping("/sign")
    public Result addCoupon(@RequestParam(value = "couponId",required = false) Long couponId){
        return couponService.addSignCoupon(couponId);
    }

    /**
     * 领取优惠卷界面
     * @return
     */
    @GetMapping("/info")
    public Result getCouponInfo(){
        return couponService.getCouponInfo();
    }

    /**
     * 领取限时优惠卷
     * @param couponId
     * @return
     */
    @PutMapping("/limit")
    public Result addLimitCoupon(@RequestParam(value = "couponId",required = false)Long couponId){
        System.out.println(couponId);
        return couponService.addLimitCoupon(couponId);
    }

    /**
     * 我的优惠卷信息
     * @return
     */
    @GetMapping("/me")
    public Result myCoupon(){
        return couponService.myCoupon();
    }
}
